package com.chenye.configuration;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

import java.util.concurrent.Future;

/**
 * @Auther:chenye
 * @Data:2018/4/11
 * @Description:
 */
@Component
public class TestAsync {
    @Async
    public Future run1(){
        System.out.println("start run1");
        System.out.println("run1 finished");
        return new AsyncResult("11111run1 finish");
    }
    @Async
    public Future run2(){
        System.out.println("start run2");
        try {
            Thread.sleep(4000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("run2 finished");
        return new AsyncResult("11111run2 finish");
    }
}
